package com.itheima.job.test07;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class TCPClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",12345);
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        OutputStream os = socket.getOutputStream();
        BufferedWriter bw  = new BufferedWriter(new OutputStreamWriter(os));
        bw.write(s);
        bw.flush();
        socket.shutdownOutput();

        InputStream is = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line;
        while ((line = br.readLine())!=null){
            System.out.println(line);
        }
        br.close();
        socket.close();
    }
}
